#!/usr/bin/php
<?php
die("Wrong idea####");
ini_set('display_errors','On');
error_reporting(1);

Class Advert_Import
{
var $production;
var $development;

function Advert_Import()
{
## PREPARE CONNECTION ##

$this->production=mysql_connect("localhost","infopark_com_ua","8888zG6Wtv1k",true);
mysql_set_charset ('utf8',$this->production);
mysql_select_db("infopark_com_ua",$this->production);

$this->development=mysql_connect("localhost","infopark_com_ua","8888zG6Wtv1k",true);
mysql_set_charset ('utf8',$this->development);
mysql_select_db("dev_infopark_com_ua",$this->development);

$this->get_data();

mysql_close($this->development);
mysql_close($this->production);
}
function get_data()
{
#$sql="SELECT * FROM node WHERE type IN ('event','place','schedule','media_gallery') AND imported=0 ORDER BY nid LIMIT 1000";
#$sql="SELECT * FROM node WHERE type IN ('event') AND nid=5963 ORDER BY nid LIMIT 100";
$sql="SELECT * FROM node WHERE type IN ('place') AND nid=15520 ORDER BY nid LIMIT 100";


$nodes=$this->LIST_Q($sql,$this->production);
#print_r($sql);
foreach($nodes as $node)
  {
    //save node
  $new_nid=$this->save_node2dev($node);
 # die('NEW NID='.$new_nid);
  #$new_nid=15703;
$this->schedule_import($new_nid,$node);

  $tbl['node_revision']=$this->get_tbl($node,'node_revision');
  $this->save2dev($new_nid,$tbl['node_revision'],'node_revision');
  
  
  $tbl['node_counter']=$this->get_tbl($node,'node_counter');
  $this->delete_before($new_nid,'node_counter');
  $this->save2dev($new_nid,$tbl['node_counter'],'node_counter');
  
  
  
  
  $tbl['file_usage']=$this->get_tbl($node,'file_usage');
  #pre($tbl['file_usage']);
  $tbl['file_managed']=$this->get_save_files($new_nid,$node,$tbl['file_usage']);
  
  /*
  
  $this->save2dev_force($new_nid,$tbl['file_usage'],'file_usage');
  
  $this->save2dev_force($new_nid,$tbl['file_managed'],'file_managed');
  
  $tbl['history']=$this->get_tbl($node,'history');
  $this->save2dev($new_nid,$tbl['history'],'history');
  */
  $tbl['taxonomy_index']=$this->get_tbl($node,'taxonomy_index');
  $this->save2dev($new_nid,$tbl['taxonomy_index'],'taxonomy_index');
  
  $tbl['url_alias']=$this->get_tbl($node,'url_alias');
  $this->save2dev($new_nid,$tbl['url_alias'],'url_alias');
  
  
  
  $this->import_fields($new_nid,$node);
  $this->update_prod_node($new_nid,$node);
  
  unset($tbl);unset($node);unset($new_nid);
  }
  
}
function schedule_import($new_nid,$node)
{
switch($node->type)
	{
	case 'event':
	$sql="SELECT * FROM `field_revision_field_schedule_event` WHERE field_schedule_event_nid =".$node->nid;
	print $sql."\n";
	$shedules=$this->LIST_Q($sql,$this->production);
	
	foreach($shedules as $shedule)
		{
		$sql1="SELECT * FROM node WHERE nid=".$shedule->entity_id;
		print $sql1."\n\n";
		$t_node=$this->ROW_Q($sql1,$this->production);
		$tnid=$this->save_node2dev($t_node);
		
		$sql1="SELECT * FROM node_revision WHERE nid=".$shedule->entity_id;
		$t_node_revision=$this->ROW_Q($sql1,$this->production);
		
		$sql2="INSERT INTO node_revision (nid,vid,uid,title,log,timestamp,status,comment,promote,sticky) 
	VALUES (".$this->Q($tnid).",".$this->Q($tnid).",".$this->Q($t_node_revision->uid).",".$this->Q($t_node_revision->title,1).",".$this->Q($t_node_revision->log,1).",".$this->Q($t_node_revision->timestamp).",".$this->Q($t_node_revision->status).",".$this->Q($t_node_revision->comment).",".$this->Q($t_node_revision->promote).",".$this->Q($t_node_revision->sticky).")";
		print $sql2."\n";
		$this->QUERY($sql2,$this->development);
		
		$sql3="SELECT * FROM field_data_field_schedule_end WHERE entity_id=".$shedule->entity_id;
		$field_data_field_schedule_end=$this->ROW_Q($sql3,$this->production);
		$sql4="INSERT INTO field_data_field_schedule_end
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_end_value) 
	VALUES (".$this->Q($field_data_field_schedule_end->entity_type,1).",".$this->Q($field_data_field_schedule_end->bundle,1).",".$this->Q($field_data_field_schedule_end->deleted).",".$this->Q($tnid).",".$this->Q($tnid).",".$this->Q($field_data_field_schedule_end->language,1).",".$this->Q($field_data_field_schedule_end->delta).",".$this->Q($field_data_field_schedule_end->field_schedule_end_value,1).")";
		print $sql4."\n";
		$this->QUERY($sql4,$this->development);
		
		$sql5="SELECT * FROM field_data_field_schedule_start WHERE entity_id=".$shedule->entity_id;
		$field_data_field_schedule_start=$this->ROW_Q($sql5,$this->production);
		$sql6="INSERT INTO field_data_field_schedule_start
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_start_value) 
	VALUES (".$this->Q($field_data_field_schedule_start->entity_type,1).",".$this->Q($field_data_field_schedule_start->bundle,1).",".$this->Q($field_data_field_schedule_start->deleted).",".$this->Q($tnid).",".$this->Q($tnid).",".$this->Q($field_data_field_schedule_start->language,1).",".$this->Q($field_data_field_schedule_start->delta).",".$this->Q($field_data_field_schedule_start->field_schedule_start_value,1).")";
		print $sql6."\n";
		$this->QUERY($sql6,$this->development);
		
		$sql7="SELECT * FROM field_data_field_schedule_price WHERE entity_id=".$shedule->entity_id;
		$field_data_field_schedule_price=$this->ROW_Q($sql7,$this->production);
		
		$sql8="INSERT INTO field_data_field_schedule_price(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_price_value,field_schedule_price_format) 
	VALUES (".$this->Q($field_data_field_schedule_price->entity_type,1).",".$this->Q($field_data_field_schedule_price->bundle,1).",".$this->Q($field_data_field_schedule_price->deleted).",".$this->Q($tnid).",".$this->Q($tnid).",".$this->Q($field_data_field_schedule_price->language,1).",".$this->Q($field_data_field_schedule_price->delta).",".$this->Q($field_data_field_schedule_price->field_schedule_price_value,1).",".$this->Q($field_data_field_schedule_price->field_schedule_price_format,1).")";
	print $sql8."\n";
		$this->QUERY($sql8,$this->development);
		
		$sql9="INSERT INTO field_data_field_schedule_event(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_event_nid) 
	VALUES (".$this->Q($shedule->entity_type,1).",".$this->Q($shedule->bundle,1).",".$this->Q($shedule->deleted).",".$this->Q($tnid).",".$this->Q($tnid).",".$this->Q($shedule->language,1).",".$this->Q($shedule->delta).",".$this->Q($new_nid).")";
		print $sql9."\n";
		$this->QUERY($sql9,$this->development);
		
		$sql10="SELECT * FROM field_data_field_schedule_place WHERE entity_id=".$shedule->entity_id;
		$field_data_field_schedule_place=$this->ROW_Q($sql10,$this->production);
		/*
		$sql11="SELECT * FROM node WHERE nid=".$field_data_field_schedule_place->field_schedule_place_nid;
		print $sql11."\n";
		$place_node=$this->ROW_Q($sql11,$this->production);
		*/
		$sql12="INSERT INTO field_data_field_schedule_place (entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_place_nid) 
	VALUES (".$this->Q($field_data_field_schedule_place->entity_type,1).",".$this->Q($field_data_field_schedule_place->bundle,1).",".$this->Q($field_data_field_schedule_place->deleted).",".$this->Q($tnid).",".$this->Q($tnid).",".$this->Q($field_data_field_schedule_place->language,1).",".$this->Q($field_data_field_schedule_place->delta).",".$this->Q($field_data_field_schedule_place->field_schedule_place_nid).")";
		print $sql12."\n";
		$this->QUERY($sql12,$this->development);
		
		
		}
	break;
	case 'place':
	$sql="SELECT * FROM `field_data_field_place_city` WHERE entity_id =".$node->nid;
	$field_data_field_place_city=$this->ROW_Q($sql,$this->production);
	
	$sql1="INSERT INTO field_data_field_place_city(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_city_tid) 
	VALUES (".$this->Q($field_data_field_place_city->entity_type,1).",".$this->Q($field_data_field_place_city->bundle,1).",".$this->Q($field_data_field_place_city->deleted).",".$this->Q($new_nid).",".$this->Q($new_nid).",".$this->Q($field_data_field_place_city->language,1).",".$this->Q($field_data_field_place_city->delta).",".$this->Q($field_data_field_place_city->field_place_city_tid).")";
	print $sql1."\n";
	$this->QUERY($sql1,$this->development);
	
	$sql2="SELECT * FROM `field_data_field_place_active_link` WHERE entity_id=".$node->nid;
	$field_data_field_place_active_link=$this->ROW_Q($sql2,$this->production);
	
	$sql3="INSERT INTO field_data_field_place_active_link
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_active_link_value) 
	VALUES (".$this->Q($field_data_field_place_active_link->entity_type,1).",".$this->Q($field_data_field_place_active_link->bundle,1).",".$this->Q($field_data_field_place_active_link->deleted).",".$this->Q($new_nid).",".$this->Q($new_nid).",".$this->Q($field_data_field_place_active_link->language,1).",".$this->Q($field_data_field_place_active_link->delta).",".$this->Q($field_data_field_place_active_link->field_place_active_link_value).")";
	print $sql3."\n";
	$this->QUERY($sql3,$this->development);
	
	$sql4="SELECT * FROM  Browse field_data_field_place_address WHERE entity_id=".$node->nid;
	$field_data_field_place_address=$this->ROW_Q($sql4);
	$sql5="INSERT INTO field_data_field_place_address(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_address_value,field_place_address_format) 
	VALUES (".$this->Q($field_data_field_place_address->entity_type,1).",".$this->Q($field_data_field_place_address->bundle,1).",".$this->Q($field_data_field_place_address->deleted).",".$this->Q($new_nid).",".$this->Q($new_nid).",".$this->Q($field_data_field_place_address->language,1).",".$this->Q($field_data_field_place_address->delta).",".$this->Q($field_data_field_place_address->field_place_address_value,1).",".$this->Q($field_data_field_place_address->field_place_address_format,1).")";
	
	$sql6="SELECT * FROM field_data_field_place_brand WHERE nid=".$node->nid;
	$field_data_field_place_brand=$this->ROW_Q($sql6);
	
		$sql7="INSERT INTO field_data_field_place_brand(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_brand_nid) 
	VALUES (".$this->Q($field_data_field_place_brand->entity_type,1).",".$this->Q($field_data_field_place_brand->bundle,1).",".$this->Q($field_data_field_place_brand->deleted).",".$this->Q($new_nid).",".$this->Q($new_nid).",".$this->Q($field_data_field_place_brand->language,1).",".$this->Q($field_data_field_place_brand->delta).",".$this->Q($field_data_field_place_brand->field_place_brand_nid).")";
	print $sql7."\n";
	$this->QUERY($sql7,$this->development);
	
	$sql8="SELECT * FROM field_data_field_place_category WHERE entity_id=".$node->nid;
	$field_data_field_place_category=$this->ROW_Q($sql8);
	
	$sql9="INSERT INTO field_data_field_place_category(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_category_tid) 
	VALUES (".$this->Q($field_data_field_place_category->entity_type,1).",".$this->Q($field_data_field_place_category->bundle,1).",".$this->Q($field_data_field_place_category->deleted).",".$this->Q($new_nid).",".$this->Q($new_nid).",".$this->Q($field_data_field_place_category->language,1).",".$this->Q($field_data_field_place_category->delta).",".$this->Q($field_data_field_place_category->field_place_category_tid).")";
	
	$this->QUERY($sql9,$this->development);
	
	die('###stop###');
	break;
	}

}
function get_save_files($nid,$node,$file_usage)
{
foreach($file_usage as $f)
  {
  $sql="SELECT * FROM file_managed WHERE fid =".$this->Q($f->fid);
  #print $sql."\n\n";
  $file_managed=$this->ROW_Q($sql,$this->production);
    //resave
      
$sql="INSERT INTO file_managed (uid,filename,uri,filemime,filesize,status,timestamp,type) VALUES (".$this->Q($file_managed->uid).",".$this->Q($file_managed->filename,1).",".$this->Q($file_managed->uri,1).",".$this->Q($file_managed->filemime,1).",".$this->Q($file_managed->filesize).",".$this->Q($file_managed->status).",".$file_managed->timestamp.",".$this->Q($file_managed->type,1).")";
  $this->QUERY($sql,$this->development);
  $fid=mysql_insert_id();
  
  $sql1="INSERT INTO file_usage(fid,module,type,id,count) VALUES (".$this->Q($fid).",".$this->Q($f->module,1).",".$this->Q($f->type,1).",".$this->Q($nid).",".$this->Q($f->count).")";
  $this->QUERY($sql,$this->development);
  }

#return $filemanaged;
}
function import_fields($new_nid,$node)
{
$this->get_and_import($new_nid,$node,'field_data_field_event_buy_a_ticket');
$this->get_and_import($new_nid,$node,'field_data_field_event_category');
      $this->get_and_import($new_nid,$node,'field_data_field_event_description');
      
      $this->get_and_import($new_nid,$node,'field_data_field_event_gallerys_list');
      
      $this->get_and_import($new_nid,$node,'field_data_field_event_images');
      $this->get_and_import($new_nid,$node,'field_data_field_event_thumbnail');
      $this->get_and_import($new_nid,$node,'field_data_field_event_ticket_id');
      $this->get_and_import($new_nid,$node,'field_data_field_for_notes');
      $this->get_and_import($new_nid,$node,'field_data_field_gallerys_list');
      $this->get_and_import($new_nid,$node,'field_data_field_license');
      /*$this->get_and_import($new_nid,$node,'field_data_field_place_active_link');
      $this->get_and_import($new_nid,$node,'field_data_field_place_address');
      $this->get_and_import($new_nid,$node,'field_data_field_place_brand');
      $this->get_and_import($new_nid,$node,'field_data_field_place_category');
      $this->get_and_import($new_nid,$node,'field_data_field_place_city');
      $this->get_and_import($new_nid,$node,'field_data_field_place_description');
      $this->get_and_import($new_nid,$node,'field_data_field_place_gallerys_list');
      $this->get_and_import($new_nid,$node,'field_data_field_place_images');
      $this->get_and_import($new_nid,$node,'field_data_field_place_phone');
      $this->get_and_import($new_nid,$node,'field_data_field_place_thumbnail');
      $this->get_and_import($new_nid,$node,'field_data_field_place_website');*/
      /*$this->get_and_import($new_nid,$node,'field_data_field_schedule_end');
      $this->get_and_import($new_nid,$node,'field_data_field_schedule_event');
      $this->get_and_import($new_nid,$node,'field_data_field_schedule_place');
      $this->get_and_import($new_nid,$node,'field_data_field_schedule_price');
      $this->get_and_import($new_nid,$node,'field_data_field_schedule_start');*/
      $this->get_and_import($new_nid,$node,'field_data_field_tags');
      $this->get_and_import($new_nid,$node,'field_data_media_description');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_allow_download');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_block_columns');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_block_rows');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_collection');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_columns');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_description');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_expose_block');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_format');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_image_info_where');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_lightbox_extras');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_media');
      $this->get_and_import($new_nid,$node,'field_data_media_gallery_rows');
      $this->get_and_import($new_nid,$node,'field_data_media_title');
      $this->get_and_import($new_nid,$node,'field_data_meta_description');
      $this->get_and_import($new_nid,$node,'field_data_meta_keywords');
      $this->get_and_import($new_nid,$node,'field_revision_body');
      $this->get_and_import($new_nid,$node,'field_revision_field_category_of_places_parent');
      $this->get_and_import($new_nid,$node,'field_revision_field_event_buy_a_ticket');
      $this->get_and_import($new_nid,$node,'field_revision_field_event_category');
      $this->get_and_import($new_nid,$node,'field_revision_field_event_description');
      $this->get_and_import($new_nid,$node,'field_revision_field_event_gallerys_list');
      $this->get_and_import($new_nid,$node,'field_revision_field_event_images');
      $this->get_and_import($new_nid,$node,'field_revision_field_event_thumbnail');
      $this->get_and_import($new_nid,$node,'field_revision_field_event_ticket_id');
      $this->get_and_import($new_nid,$node,'field_revision_field_for_notes');
      $this->get_and_import($new_nid,$node,'field_revision_field_gallerys_list');
      $this->get_and_import($new_nid,$node,'field_revision_field_license');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_active_link');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_address');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_brand');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_category');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_city');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_description');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_gallerys_list');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_images');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_phone');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_thumbnail');
      $this->get_and_import($new_nid,$node,'field_revision_field_place_website');
      $this->get_and_import($new_nid,$node,'field_revision_field_schedule_end');
      $this->get_and_import($new_nid,$node,'field_revision_field_schedule_event');
      $this->get_and_import($new_nid,$node,'field_revision_field_schedule_place');
      $this->get_and_import($new_nid,$node,'field_revision_field_schedule_price');
      $this->get_and_import($new_nid,$node,'field_revision_field_schedule_start');
      $this->get_and_import($new_nid,$node,'field_revision_field_tags');
      $this->get_and_import($new_nid,$node,'field_revision_media_description');
      $this->get_and_import($new_nid,$node,'field_revision_media_gallery_allow_download');
      $this->get_and_import($new_nid,$node,'field_revision_media_gallery_block_columns');
      $this->get_and_import($new_nid,$node,'field_revision_media_gallery_block_rows');
      $this->get_and_import($new_nid,$node,'field_revision_media_gallery_collection');
      	$this->get_and_import($new_nid,$node,'field_revision_media_gallery_columns');
      	$this->get_and_import($new_nid,$node,'field_revision_media_gallery_description');
      	$this->get_and_import($new_nid,$node,'field_revision_media_gallery_expose_block');
	$this->get_and_import($new_nid,$node,'field_revision_media_gallery_format');
      	$this->get_and_import($new_nid,$node,'field_revision_media_gallery_image_info_where');
      	$this->get_and_import($new_nid,$node,'field_revision_media_gallery_lightbox_extras');
      	$this->get_and_import($new_nid,$node,'field_revision_media_gallery_media');
      	$this->get_and_import($new_nid,$node,'field_revision_media_gallery_rows');
      	$this->get_and_import($new_nid,$node,'field_revision_media_title');
      	$this->get_and_import($new_nid,$node,'field_revision_meta_description');
      	$this->get_and_import($new_nid,$node,'field_revision_meta_keywords');
}
function get_and_import($new_nid,$node,$tbl)
{
$data=$this->get_tbl($node,$tbl);

$this->save2dev($new_nid,$data,$tbl);
}
function get_tbl($node,$tbl)
{
      switch($tbl)
      {
      case 'url_alias':
      $sql="SELECT * FROM ".$tbl." WHERE source='node/".$node->nid."'";
      break;
      case 'file_usage':
      $sql="SELECT * FROM ".$tbl." WHERE type='node' AND id=".$node->nid;
      break;
      case 'node_revision':
      case 'node_counter':
      
      case 'history':
      case 'taxonomy_index':
      $sql="SELECT * FROM ".$tbl." WHERE nid=".$node->nid;
      break;
      case 'field_data_field_event_buy_a_ticket':
      case 'field_data_field_event_category':
      case 'field_data_field_event_description':
      case 'field_data_field_event_gallerys_list':
      case 'field_data_field_event_images':
      case 'field_data_field_event_thumbnail':
      case 'field_data_field_event_ticket_id':
      case 'field_data_field_for_notes':
      case 'field_data_field_gallerys_list':
      case 'field_data_field_license':
      /*case 'field_data_field_place_active_link':
      case 'field_data_field_place_address':
      case 'field_data_field_place_brand':
      case 'field_data_field_place_category':
      #case 'field_data_field_place_city':
      case 'field_data_field_place_description':
      case 'field_data_field_place_gallerys_list':
      case 'field_data_field_place_images':
      case 'field_data_field_place_phone':
      case 'field_data_field_place_thumbnail':
      case 'field_data_field_place_website':
      case 'field_data_field_schedule_end':
      case 'field_data_field_schedule_event':
      case 'field_data_field_schedule_place':
      case 'field_data_field_schedule_price':
      case 'field_data_field_schedule_start':*/
      case 'field_data_field_tags':
      case 'field_data_media_description':
      case 'field_data_media_gallery_allow_download':
      case 'field_data_media_gallery_block_columns':
      case 'field_data_media_gallery_block_rows':
      case 'field_data_media_gallery_collection':
      case 'field_data_media_gallery_columns':
      case 'field_data_media_gallery_description':
      case 'field_data_media_gallery_expose_block':
      case 'field_data_media_gallery_format':
      case 'field_data_media_gallery_image_info_where':
      case 'field_data_media_gallery_lightbox_extras':
      case 'field_data_media_gallery_media':
      case 'field_data_media_gallery_rows':
      case 'field_data_media_title':
      case 'field_data_meta_description':
      case 'field_data_meta_keywords':
      case 'field_revision_body':
      case 'field_revision_field_category_of_places_parent':
      case 'field_revision_field_event_buy_a_ticket':
      case 'field_revision_field_event_category':
      case 'field_revision_field_event_description':
      case 'field_revision_field_event_gallerys_list':
      case 'field_revision_field_event_images':
      case 'field_revision_field_event_thumbnail':
      case 'field_revision_field_event_ticket_id':
      case 'field_revision_field_for_notes':
      case 'field_revision_field_gallerys_list':
      case 'field_revision_field_license':
      case 'field_revision_field_place_active_link':
      case 'field_revision_field_place_address':
      case 'field_revision_field_place_brand':
      case 'field_revision_field_place_category':
      case 'field_revision_field_place_city':
      case 'field_revision_field_place_description':
      case 'field_revision_field_place_gallerys_list':
      case 'field_revision_field_place_images':
      case 'field_revision_field_place_phone':
      case 'field_revision_field_place_thumbnail':
      case 'field_revision_field_place_website':
      case 'field_revision_field_schedule_end':
      case 'field_revision_field_schedule_event':
      case 'field_revision_field_schedule_place':
      case 'field_revision_field_schedule_price':
      case 'field_revision_field_schedule_start':
      case 'field_revision_field_tags':
      case 'field_revision_media_description':
      case 'field_revision_media_gallery_allow_download':
      case 'field_revision_media_gallery_block_columns':
      case 'field_revision_media_gallery_block_rows':
      case 'field_revision_media_gallery_collection':
      	case 'field_revision_media_gallery_columns':
      	case 'field_revision_media_gallery_description':
      	case 'field_revision_media_gallery_expose_block':
	case 'field_revision_media_gallery_format':
      	case 'field_revision_media_gallery_image_info_where':
      	case 'field_revision_media_gallery_lightbox_extras':
      	case 'field_revision_media_gallery_media':
      	case 'field_revision_media_gallery_rows':
      	case 'field_revision_media_title':
      	case 'field_revision_meta_description':
      	case 'field_revision_meta_keywords':
      $sql="SELECT * FROM ".$tbl." WHERE entity_type='node' AND entity_id=".$node->nid;
      break;
      }
    #  print $sql."\n";
return $this->LIST_Q($sql,$this->production);
}
### SAVE noDE ###
function save_node2dev($node)
{
$sql="INSERT INTO node(type,language,title,uid,status,created,changed,comment) 
	VALUES (".$this->Q($node->type,1).",".$this->Q($node->language,1).",".$this->Q($node->title,1).",".$this->Q($node->uid).",".$this->Q($node->status).",".$this->Q($node->created).",".$this->Q($node->changed).",".$node->comment.")";
	
	print $sql."\n";
	$this->QUERY($sql,$this->development);
	$new_nid=mysql_insert_id($this->development);
	return $new_nid;

}
function delete_before($nid,$tbl)
{
$sql="DELETE FROM ".$tbl." WHERE nid=".$nid;

print $sql."\n";
$this->QUERY($sql,$this->development);
}
###
###Special force import with hight record priority
###Use for tbl:file_usage,filemanaged
###
/*
function save2dev_force($nid,$nodes,$tbl)
{
foreach($nodes as $node)
{
$sql[0]="SELECT * FROM ".$tbl." WHERE type='node' AND fid=".$this->Q($node->fid);  
print $sql[0]."\n\n";
$row=$this->ROW_Q($sql[0],$this->development);
if($row['fid'])
{
//need delete
$sql[1]="DELETE FROM ".$tbl." WHERE fid=".$node->fid;

print $sql[1]."\n\n";
$this->QUERY($sql[1],$this->development);
}
switch($tbl)
  {
  case 'file_usage':
  $sql[2]="INSERT INTO ".$tbl."(fid,module,type,id,count) VALUES (".$this->Q($node->fid).",".$this->Q($node->module,1).",".$this->Q($node->type,1).",".$this->Q($nid).",".$this->Q($node->count).")";
  
  break;
  case 'file_managed':
$sql[2]="INSERT INTO ".$tbl."(fid,uid,filename,uri,filemime,filesize,status,timestamp,type) VALUES (".$this->Q($node->fid).",".$this->Q($node->uid).",".$this->Q($node->filename,1).",".$this->Q($node->uri,1).",".$this->Q($node->filemime,1).",".$this->Q($node->filesize).",".$this->Q($node->status).",".$node->timestamp.",".$this->Q($node->type,1).")";
  
  break;
  }
  print $sql[2]."\n\n";
  $this->QUERY($sql[2],$this->development);
  }
}*/
function save2dev($nid,$nodes,$tbl)
{
foreach($nodes as $node)
{
      switch($tbl)
	{
	case 'url_alias':
	$sql="INSERT INTO ".$tbl." (source,alias,language) 
	VALUES (".$this->Q('node/'.$nid,1).",".$this->Q($node->alias,1).",".$this->Q($node->language,1).")";
	break;
	case 'taxonomy_index':
	$sql="INSERT INTO ".$tbl." (nid,tid,sticky,created) 
	VALUES (".$this->Q($nid).",".$this->Q($node->tid).",".$this->Q($node->sticky).",".$this->Q($node->created).")";
	break;
	case 'node_revision':
	$sql="INSERT INTO ".$tbl." (nid,vid,uid,title,log,timestamp,status,comment,promote,sticky) 
	VALUES (".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->uid).",".$this->Q($node->title,1).",".$this->Q($node->log,1).",".$this->Q($node->timestamp).",".$this->Q($node->status).",".$this->Q($node->comment).",".$this->Q($node->promote).",".$this->Q($node->sticky).")";
	break;
	case 'node_counter':
	$sql="INSERT INTO ".$tbl." (nid,totalcount,daycount,timestamp) VALUES (".$nid.",".$this->Q($node->totalcount).",".$this->Q($node->daycount).",".$this->Q($node->timestamp).")";
	break;
	case 'history':
	$sql="INSERT INTO ".$tbl." (uid,nid,timestamp) VALUES (".$this->Q($node->uid).",".$nid.",".$this->Q($node->timestamp).")";
	break;
	case 'field_data_field_event_buy_a_ticket':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_buy_a_ticket_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_buy_a_ticket_value).")";
	break;
	case 'field_data_field_event_category':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_category_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_category_tid).")";
	break;
	case 'field_data_field_event_description':
	
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_description_value,field_event_description_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_description_value,1).",".$this->Q($node->field_event_description_format,1).")";
	
	#die($sql."\n");
	
	break;
	case 'field_data_field_event_gallerys_list':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_gallerys_list_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_gallerys_list_tid).")";
	break;
	case 'field_data_field_event_images':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_images_fid,field_event_images_alt,field_event_images_title,field_event_images_width,field_event_images_height) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_images_fid).",".$this->Q($this->field_event_images_alt,1).",".$this->Q($node->field_event_images_title,1).",".$this->Q($node->field_event_images_width).",".$this->Q($node->field_event_images_height).")";
	break;
	case 'field_data_field_event_thumbnail':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_thumbnail_fid,field_event_thumbnail_alt,field_event_thumbnail_title,field_event_thumbnail_width,field_event_thumbnail_height) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_thumbnail_fid).",".$this->Q($this->field_event_thumbnail_alt,1).",".$this->Q($node->field_event_thumbnail_title,1).",".$this->Q($node->field_event_thumbnail_width).",".$this->Q($node->field_event_thumbnail_height).")";
	break;
	case 'field_data_field_event_ticket_id':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_ticket_id_value,field_event_ticket_id_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_ticket_id_value,1).",".$this->Q($node->field_event_ticket_id_format,1).")";
	
	break;
	case  'field_data_field_for_notes':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_for_notes_value,field_for_notes_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_for_notes_value,1).",".$this->Q($node->field_for_notes_format,1).")";
	
	break;
	case 'field_data_field_gallerys_list':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_gallerys_list_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_gallerys_list_tid).")";
	break;
	case 'field_data_field_license':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_license_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_license_value,1).")";
	break;
	/*case 'field_data_field_place_active_link':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_active_link_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_active_link_value).")";
	break;
	case 'field_data_field_place_address':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_address_value,field_place_address_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_address_value,1).",".$this->Q($node->field_place_address_format,1).")";
	break;
	case 'field_data_field_place_brand':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_brand_nid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_brand_nid).")";
	break;
	case 'field_data_field_place_category':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_category_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_category_tid).")";
	break;
	case 'field_data_field_place_city':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_city_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_city_tid).")";
	break;
	case 'field_data_field_place_description':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_description_value,field_place_description_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_description_value,1).",".$this->Q($node->field_place_description_format,1).")";
	break;
	case 'field_data_field_place_gallerys_list':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_gallerys_list_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_gallerys_list_tid).")";
	break;
	case 'field_data_field_place_images':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_images_fid,field_place_images_alt,field_place_images_title,field_place_images_width,field_place_images_height) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_images_fid).",".$this->Q($this->field_place_images_alt,1).",".$this->Q($node->field_place_images_title,1).",".$this->Q($node->field_place_images_width).",".$this->Q($node->field_place_images_height).")";
	break;
	case 'field_data_field_place_phone':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_phone_value,field_place_phone_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_phone_value,1).",".$this->Q($node->field_place_phone_format,1).")";
	break;
	case 'field_data_field_place_thumbnail':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_thumbnail_fid,field_place_thumbnail_alt,field_place_thumbnail_title,field_place_thumbnail_width,field_place_thumbnail_height) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_thumbnail_fid).",".$this->Q($this->field_place_thumbnail_alt,1).",".$this->Q($node->field_place_thumbnail_title,1).",".$this->Q($node->field_place_thumbnail_width).",".$this->Q($node->field_place_thumbnail_height).")";
	break;
	case 'field_data_field_place_website':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_website_value,field_place_website_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_website_value,1).",".$this->Q($node->field_place_website_format,1).")";
	break;*/
	/*case 'field_data_field_schedule_end':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_end_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_end_value,1).")";
	break;
	case 'field_data_field_schedule_event':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_event_nid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_event_nid).")";
	break;
	case 'field_data_field_schedule_place':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_place_nid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_place_nid).")";
	break;
	case 'field_data_field_schedule_price':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_price_value,field_schedule_price_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_price_value,1).",".$this->Q($node->field_schedule_price_format,1).")";
	break;
	case 'field_data_field_schedule_start':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_start_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_start_value,1).")";
	break;*/
	case 'field_data_field_tags':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_tags_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_tags_tid).")";
	break;
	case 'field_data_media_description':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_description_value,media_description_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_description_value,1).",".$this->Q($node->media_description_format,1).")";
	break;
	case 'field_data_media_gallery_allow_download':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_allow_download_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_allow_download_value).")";
	break;
	case 'field_data_media_gallery_block_columns':
	  $sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_block_columns_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_block_columns_value).")";
	break;
	case 'field_data_media_gallery_block_rows':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_block_rows_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_block_rows_value).")";
	break;
	case 'field_data_media_gallery_collection':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_collection_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_collection_tid).")";
	break;
	case 'field_data_media_gallery_columns':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_columns_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_columns_value).")";
	break;
	case 'field_data_media_gallery_description':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_description_value,media_gallery_description_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_description_value,1).",".$this->Q($node->media_gallery_description_format,1).")";
	break;
	case 'field_data_media_gallery_expose_block':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_expose_block_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_expose_block_value).")";
	break;
	case 'field_data_media_gallery_format':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_format_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_format_value,1).")";
	break;
	case 'field_data_media_gallery_image_info_where':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_image_info_where_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_image_info_where_value,1).")";
	break;
	case 'field_data_media_gallery_lightbox_extras':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_lightbox_extras_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_lightbox_extras_value).")";
	break;
	case 'field_data_media_gallery_media':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_media_fid,media_gallery_media_title,media_gallery_media_data) 	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_media_fid).",".$this->Q($node->media_gallery_media_title,1).",".$this->Q($node->media_gallery_media_data,1).")";
	break;
	case 'field_data_media_gallery_rows':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_rows_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_rows_value).")";
	break;
	case 'field_data_media_title':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,_media_title_value,_media_title_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_media_gallery_description_value,1).",".$this->Q($node->field_media_gallery_description_format,1).")";
	break;
	case 'field_data_meta_description':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,meta_description_metatags_quick) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->meta_description_metatags_quick,1).")";
	break;
	case 'field_data_meta_keywords':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,meta_keywords_metatags_quick) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->meta_keywords_metatags_quick,1).")";
	break;
	case 'field_revision_body':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,body_value,body_summary,body_format)
 	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->body_value,1).",".$this->Q($node->body_summary,1).",".$this->Q($node->body_format,1).")";
	break;
	case 'field_revision_field_category_of_places_parent':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_category_of_places_parent_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_category_of_places_parent_tid).")";
	break;
	case 'field_revision_field_event_buy_a_ticket':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_buy_a_ticket_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_buy_a_ticket_value).")";
	break;
	case 'field_revision_field_event_category':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_category_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_category_tid).")";
	break;
	case 'field_revision_field_event_description':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_description_value,field_event_description_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_description_value,1).",".$this->Q($node->field_event_description_format,1).")";
	break;
	case 'field_revision_field_event_gallerys_list':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_gallerys_list_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_gallerys_list_tid).")";
	break;
	case 'field_revision_field_event_images':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_images_fid,field_event_images_alt,field_event_images_title,field_event_images_width,field_event_images_height) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_images_fid).",".$this->Q($this->field_event_images_alt,1).",".$this->Q($node->field_event_images_title,1).",".$this->Q($node->field_event_images_width).",".$this->Q($node->field_event_images_height).")";
	break;
	case 'field_revision_field_event_thumbnail':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_thumbnail_fid,field_event_thumbnail_alt,field_event_thumbnail_title,field_event_thumbnail_width,field_event_thumbnail_height) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_thumbnail_fid).",".$this->Q($this->field_event_thumbnail_alt,1).",".$this->Q($node->field_event_thumbnail_title,1).",".$this->Q($node->field_event_thumbnail_width).",".$this->Q($node->field_event_thumbnail_height).")";
	break;
	case 'field_revision_field_event_ticket_id':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_event_ticket_id_value,field_event_ticket_id_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_event_ticket_id_value,1).",".$this->Q($node->field_event_ticket_id_format,1).")";
	break;
	case 'field_revision_field_for_notes':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_for_notes_value,field_for_notes_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_for_notes_value,1).",".$this->Q($node->field_for_notes_format,1).")";
	break;
	case 'field_revision_field_gallerys_list':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_gallerys_list_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_gallerys_list_tid).")";
	break;
	case 'field_revision_field_license':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_license_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_license_value,1).")";
	break;
	case 'field_revision_field_place_active_link':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_active_link_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_active_link_value,1).")";
	break;
	case 'field_revision_field_place_address':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_address_value,field_place_address_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_address_value,1).",".$this->Q($node->field_place_address_format,1).")";
	break;
	case 'field_revision_field_place_brand':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_brand_nid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_brand_nid).")";
	break;
	case 'field_revision_field_place_category':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_category_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_category_tid).")";
	break;
	case 'field_revision_field_place_city':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_city_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_city_tid).")";
	break;
	case 'field_revision_field_place_description':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_description_value,field_place_description_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_description_value,1).",".$this->Q($node->field_place_description_format,1).")";
	break;
	case 'field_revision_field_place_gallerys_list':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_gallerys_list_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_gallerys_list_tid).")";
	break;
	case 'field_revision_field_place_images':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_images_fid,field_place_images_alt,field_place_images_title,field_place_images_width,field_place_images_height) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_images_fid).",".$this->Q($this->field_place_images_alt,1).",".$this->Q($node->field_place_images_title,1).",".$this->Q($node->field_place_images_width).",".$this->Q($node->field_place_images_height).")";
	break;
	case 'field_revision_field_place_phone':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_phone_value,field_place_phone_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_phone_value,1).",".$this->Q($node->field_place_phone_format,1).")";
	break;
	case 'field_revision_field_place_thumbnail':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_thumbnail_fid,field_place_thumbnail_alt,field_place_thumbnail_title,field_place_thumbnail_width,field_place_thumbnail_height) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_thumbnail_fid).",".$this->Q($this->field_place_thumbnail_alt,1).",".$this->Q($node->field_place_thumbnail_title,1).",".$this->Q($node->field_place_thumbnail_width).",".$this->Q($node->field_place_thumbnail_height).")";
	break;
	case 'field_revision_field_place_website':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_place_website_value,field_place_website_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_place_website_value,1).",".$this->Q($node->field_place_website_format,1).")";
	break;
	case 'field_revision_field_schedule_end':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_end_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_end_value,1).")";
	break;
	case 'field_revision_field_schedule_event':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_event_nid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_event_nid).")";
	break;
	case 'field_revision_field_schedule_place':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_place_nid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_place_nid).")";
	break;
	case'field_revision_field_schedule_price':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_price_value,field_schedule_price_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_price_value,1).",".$this->Q($node->field_schedule_price_format,1).")";
	break;
	case 'field_revision_field_schedule_start':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_schedule_start_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_schedule_start_value,1).")";
	break;
	case 'field_revision_field_tags':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,field_tags_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->field_tags_tid).")";
	break;
	case 'field_revision_media_description':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_description_value,media_description_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_description_value,1).",".$this->Q($node->media_description_format,1).")";
	break;
	case 'field_revision_media_gallery_allow_download':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_allow_download_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_allow_download_value).")";
	break;
	case 'field_revision_media_gallery_block_columns':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_block_columns_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_block_columns_value).")";
	break;
	case 'field_revision_media_gallery_block_rows':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_block_rows_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_block_rows_value).")";
	break;
	case 'field_revision_media_gallery_collection':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_collection_tid) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_collection_tid).")";
	break;
	case 'field_revision_media_gallery_columns':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_columns_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_columns_value).")";
	break;
	case 'field_revision_media_gallery_description':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_description_value,media_gallery_description_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_description_value,1).",".$this->Q($node->media_gallery_description_format,1).")";
	break;
	case 'field_revision_media_gallery_expose_block':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_expose_block_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_expose_block_value).")";
	break;
	case 'field_revision_media_gallery_format':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_format_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_format_value,1).")";
	break;
	case 'field_revision_media_gallery_image_info_where':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_image_info_where_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_image_info_where_value,1).")";
	break;
	case 'field_revision_media_gallery_lightbox_extras':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_lightbox_extras_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_lightbox_extras_value).")";
	break;
	case 'field_revision_media_gallery_media':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_media_fid,media_gallery_media_title,media_gallery_media_data) 	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_media_fid).",".$this->Q($node->media_gallery_media_title,1).",".$this->Q($node->media_gallery_media_data,1).")";
	break;
	case 'field_revision_media_gallery_rows':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,media_gallery_rows_value) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_gallery_rows_value).")";
	break;
	case 'field_revision_media_title':
	$sql="INSERT INTO ".$tbl."(entity_type,bundle,deleted,entity_id,revision_id,language,deltamedia_title_value,media_title_format) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->media_title_value,1).",".$this->Q($node->media_title_format,1).")";
	break;
	case 'field_revision_meta_description':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,meta_description_metatags_quick) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->meta_description_metatags_quick,1).")";
	break;
	case 'field_revision_meta_keywords':
	$sql="INSERT INTO ".$tbl."
	(entity_type,bundle,deleted,entity_id,revision_id,language,delta,meta_keywords_metatags_quick) 
	VALUES (".$this->Q($node->entity_type,1).",".$this->Q($node->bundle,1).",".$this->Q($node->deleted).",".$this->Q($nid).",".$this->Q($nid).",".$this->Q($node->language,1).",".$this->Q($node->delta).",".$this->Q($node->meta_keywords_metatags_quick,1).")";
	break;
	}
	
  print $sql."\n\n";
  $this->QUERY($sql,$this->development);
 }
}

function update_prod_node($nid,$node)
{
$sql0="UPDATE node SET vid=".$nid." WHERE nid=".$nid;
print $sql0."\n\n";
$this->QUERY($sql0,$this->development);

$sql="UPDATE node SET imported=".$this->Q($nid)." WHERE nid=".$this->Q($node->nid);
print $sql."\n";
$this->QUERY($sql,$this->production);
}
function Q($str,$string=0)
{
return ($string?"'":"").mysql_escape_string($str).($string?"'":"");
}
function QUERY($sql,$conn)
{
#$$result=mysql_query($sql,$conn);
$result=mysql_query($sql,$conn) or die($sql."\n\n".mysql_error($conn));
return $result;
}
function ROW_Q($sql,$conn)
{
$result=$this->QUERY($sql,$conn);
$r=mysql_fetch_object($result);
if(count($r)==0)$r=false;
return $r;
}
function LIST_Q($sql,$conn)
{

$result=$this->QUERY($sql,$conn);
while($r=mysql_fetch_object($result))
  {
  $data[]=$r;
  }
  
  if(count($data)==0)$data=false;
  return $data;
}

}
function pre($array)
{
print_r($array);
}

$AI=new Advert_Import;


print "### GOOD FINALL ###\n\n";
?>